package com.effective;

import java.util.TreeSet;

public class CompareUser implements Comparable<CompareUser>{
	
	public int age;
	
	@Override
	public int compareTo(CompareUser o) {
		return age - o.age;
	}
	
	@Override
	public String toString() {
		return "CompareUser [age=" + age + "]";
	}

	public static void main(String[] args) {
		CompareUser cu1 = new CompareUser();
		cu1.age = 12;
		CompareUser cu2 = new CompareUser();
		cu2.age = 14;
		TreeSet<CompareUser> set = new TreeSet<>();
		set.add(cu2);
		set.add(cu1);
		System.out.println(set);

	}
}
